<template>
  <div class="record">
    <div>
      <div class="record-header">
        <div class="record-header-ingput" @click="setTime(1)">
          <input type="text" placeholder="开始时间" v-model="search.startTime">
        </div>
        <div class="record-header-ingput" @click="setTime(2)">
          <input type="text" placeholder="结束时间" v-model="search.endTime">
        </div>
        <img src="../../assets/agent/search.png" @click="doSearch" />
      </div>
      <nut-datepicker :is-visible="showDate" title="请选择日期" type="date" startDate="2021-01-01" endDate="2300-10-05"
        @close="close" @choose="choose">
      </nut-datepicker>
    </div>
    <div class="record-item" v-for="(data,index) in orderData" :key="index">
      <div class="record-item-title">
        <div class="record-item-title-left" v-if="data.type==1">
          <img src="../../assets/record/type_1.png">
          订单数据
        </div>
        <div class="record-item-title-left" v-else-if="data.type==2">
          <img src="../../assets/record/type_2.png">
          大盘使用率
        </div>
        <div class="record-item-title-left" v-else>
          <img src="../../assets/record/type_3.png">
          信息数据
        </div>
        <div class="record-item-title-right">
          <span @click="setType(data,index)" :class="data.active==item.value?'active':''" v-for="(item,index) in dayType"
            :key="index">{{item.name}}</span>
        </div>
      </div>
      <div class="record-item-content">
        <div class="record-item-content-row">
          <div class="record-item-content-name">订单数</div>
          <p>88</p>
        </div>
        <div class="record-item-content-row">
          <div class="record-item-content-name">金额</div>
          <p>88</p>
        </div>
        <div class="record-item-content-row">
          <div class="record-item-content-name">均价</div>
          <p>88</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        search: {
          startTime: "",
          endTime: "",
        },
        timeType: "1",
        showDate: false,
        dayType: [{
          name: "所有",
          value: 0,
        }, {
          name: "今日",
          value: 1,
        }, {
          name: "本周",
          value: 2,
        }, {
          name: "本月",
          value: 3,
        }, ],
        orderData: [{
          type: 1,
          name: "订单数据",
          order: 88,
          money: 89,
          average: 90,
          active: 1
        }, {
          type: 2,
          name: "订单数据",
          order: 88,
          money: 89,
          average: 90,
          active: 2
        }, {
          type: 3,
          name: "订单数据",
          order: 88,
          money: 89,
          average: 90,
          active: 0
        }, ]
      }
    },
    mounted() {
      document.title = "数据"
    },
    methods: {
      setTime(state) {
        this.timeType = state
        this.showDate = true
      },
      choose(e) {
        if (this.timeType == 1) {
          this.search.startTime = e[3]
        } else {
          this.search.endTime = e[3]
        }
      },
      close() {
        this.showDate = false

      },
      doSearch() {
        console.info("this.search", this.search)
      },
      setType(data, index) {
        data.active = index
      },
    }
  };
</script>

<style lang="less" scoped>
  .record {
    padding: 15px;
    box-sizing: border-box;

    .record-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 100%;

      .record-header-ingput {
        width: 136px;
        height: 33px;
        border-radius: 20px;
        background-color: #E5E5E5;

        input {
          width: 100%;
          height: 33px;
          text-align: center;
        }
      }

      img {
        width: 22px;
      }
    }

    .record-item {
      width: 100%;
      height: 115px;
      background: #FFFFFF;
      box-shadow: 0px 0px 9px 0px rgba(51, 51, 51, 0.09);
      border-radius: 5px;
      margin: 15px auto 0px auto;
      padding: 0 12px;
      box-sizing: border-box;

      .record-item-title {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 9px 0px;
        border-bottom: 1px solid #eee;
        box-sizing: border-box;

        .record-item-title-left {
          display: flex;
          justify-content: flex-start;
          align-items: center;
          color: #1677FF;
          font-weight: 800;
          font-size: 16px;
          min-width: 120px;
          width: 120px;

          img {
            margin-right: 12px;
            height: 20px;
            width: 16px;
          }
        }

        .record-item-title-right {
          display: flex;
          justify-content: flex-start;
          align-items: center;

          span {
            padding: 2px 8px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: bold;
            border: 1px solid #999;
            color: #999;
            margin-left: 3px;
          }

          .active {
            border: 1px solid #1677FF;
            color: #1677FF;
          }
        }
      }

      .record-item-content {
        width: 100%;
        display: flex;
        justify-content: flex-start;
        align-items: center;
      }

      .record-item-content-row {
        width: 33.33%;
        text-align: center;
        font-weight: bold;
        color: #333;

        .record-item-content-name {
          padding: 12px 0;
          width: 100%;
          box-sizing: border-box;
        }

        p {
          margin: 0;
        }
      }
    }
  }

  @media screen and (min-width: 300px)and (max-width: 320px) {
    .record .record-item .record-item-title .record-item-title-left {
      font-size: 13px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      min-width: 80px;
      width: 80px;
    }
    .record .record-header .record-header-ingput{
      width:116px;
      height:28px;
    }
    .record .record-header .record-header-ingput input{
      height:28px;
    }
    .record .record-header img{
      width:19px;
    }
  }
</style>
